/* GUI CONVERTED from rcpsmt.p (converter v1.76) Fri May  3 13:21:23 2002 */
/* rcpsmt.p - Release Management Customer Schedules                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.11.1.7 $                                                      */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.0    LAST MODIFIED: 01/29/92           BY: WUG *F110*          */
/* REVISION: 7.0    LAST MODIFIED: 03/17/92           BY: WUG *F312*          */
/* REVISION: 7.0    LAST MODIFIED: 03/26/92           BY: WUG *F323*          */
/* REVISION: 7.0    LAST MODIFIED: 04/20/92           BY: WUG *F416*          */
/* REVISION: 7.0    LAST MODIFIED: 07/01/92           BY: afs *F723*          */
/* REVISION: 7.3    LAST MODIFIED: 10/12/92           BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 03/17/93           BY: WUG *G833*          */
/* REVISION: 7.3    LAST MODIFIED: 08/13/93           BY: WUG *GE19*          */
/* REVISION: 7.3    LAST MODIFIED: 06/14/94           BY: dpm *FO75*          */
/* REVISION: 7.3    LAST MODIFIED: 06/14/94           BY: dpm *FO82*          */
/* REVISION: 7.3    LAST MODIFIED: 09/20/94           BY: jpm *GM74*          */
/* REVISION: 7.3    LAST MODIFIED: 11/05/94           BY: rxm *GN17*          */
/* REVISION: 7.3    LAST MODIFIED: 03/22/95           BY: aed *G0J0*          */
/* REVISION: 7.3    LAST MODIFIED: 03/29/95           BY: bcm *G0JS*          */
/* REVISION: 8.5    LAST MODIFIED: 04/24/95           BY: dpm *J044*          */
/* REVISION: 7.4    LAST MODIFIED: 08/14/95           BY: vrn *G0V2*          */
/* REVISION: 7.4    LAST MODIFIED: 08/29/95           BY: bcm *G0TB*          */
/* REVISION: 7.4    LAST MODIFIED: 09/16/95           BY: vrn *G0X9*          */
/* REVISION: 7.3    LAST MODIFIED: 10/18/95           BY: vrn *G0Z6*          */
/* REVISION: 7.4    LAST MODIFIED: 11/02/95           BY: vrn *G0YL*          */
/* REVISION: 7.4    LAST MODIFIED: 05/22/96           BY: jpm *H0L5*          */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96           BY: TSI *K005*          */
/* REVISION: 8.6    LAST MODIFIED: 06/30/97           BY: axv *K0CB*          */
/* REVISION: 8.6      LAST MODIFIED: 08/08/97   BY: *J1YQ* Suresh Nayak       */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 07/07/99   BY: *J3HR* Sachin Shinde      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 01/25/01   BY: *M10W* Sandeep p.         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.11.1.5     BY: Jean Miller       DATE: 03/22/01 ECO: *P008*    */
/* Revision: 1.11.1.6     BY: Rajesh Lokre      DATE: 05/11/01 ECO: *P00V*    */
/* $Revision: 1.11.1.7 $    BY: Katie Hilbert     DATE: 04/15/02 ECO: *P03J*    */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* PLANNING SCHEDULE MAINT */

{mfdtitle.i "2+ "}

define new shared variable cmtindx like cmt_indx.
define new shared variable global_schtype as integer.
define new shared variable impexp   like mfc_logical no-undo.

define variable schtype        as integer initial 1.
define variable i              as integer.
define variable del-yn         like mfc_logical.
define variable yn             like mfc_logical.
define variable cmmts          like soc_hcmmts label "Comments".
define variable this_eff_start as date.
define variable sch_recid      as recid.
define variable impexp_label   as character format "x(8)" no-undo.

define new shared frame a.

define buffer prev_sch_mstr for sch_mstr.
define buffer prev_schd_det for schd_det.

{rcordfrm.i}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
{rcordfma.i}
   sch_rlse_id colon 14
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

find first soc_ctrl no-lock.

repeat transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* GET SCHEDULED ORDER */
   {rcgetord.i "old" " " "validate"}

   /* IF NOT CONNECTED, ISSUE ERROR AND UNDO */
   if si_db <> global_db
      and not connected(si_db)
   then do:
      /* DATABASE NOT CONNECTED */
      {pxmsg.i &MSGNUM=2510 &ERRORLEVEL=4 &MSGARG1=si_db}
      undo, retry.
   end.

   /* GET SCHEDULE RECORD */
   {rcgetrel.i}

   cmmts = soc_hcmmts.
   if sch_cmtindx > 0 then
      cmmts = yes.

   FORM /*GUI*/ 
      
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
cmmts          colon 20
      sch_cr_date    colon 55
      sch_cr_time    no-label
      sch_sd_pat     colon 20 label "SDP Code"
      sch_cumulative colon 55
      sch_sd_time    colon 20 label "SDT Code"
      sch_prp_int    colon 20
      sch_prp_ext    colon 20
      sch_sd_dates   colon 55
      sch_pcr_qty    colon 20
      sch_eff_start  colon 55 label "Active Start"
      sch_pcs_date   colon 20
      sch_eff_end    colon 55 label "Active End"
    SKIP(.4)  /*GUI*/
with frame sched_data attr-space side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-sched_data-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame sched_data = F-sched_data-title.
 RECT-FRAME-LABEL:HIDDEN in frame sched_data = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame sched_data =
  FRAME sched_data:HEIGHT-PIXELS - RECT-FRAME:Y in frame sched_data - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME sched_data = FRAME sched_data:WIDTH-CHARS - .5.  /*GUI*/


   /* SET EXTERNAL LABELS */
   setFrameLabels(frame sched_data:handle).

   display
      sch_cr_date
      string(sch_cr_time,"HH:MM:SS") format "x(8)" @ sch_cr_time
   with frame sched_data.

   ststatus = stline[2].
   status input ststatus.

   display
      cmmts
      sch_sd_pat
      sch_sd_time
      sch_prp_int
      sch_prp_ext
      sch_pcr_qty
      sch_pcs_date
      sch_cumulative
      sch_sd_dates
      sch_eff_start
      sch_eff_end
   with frame sched_data.

   do on error undo , retry:
/*GUI*/ if global-beam-me-up then undo, leave.

      set
         cmmts
         sch_sd_pat
         sch_sd_time
         sch_prp_int
         sch_prp_ext
         sch_pcr_qty
         sch_pcs_date
         sch_cumulative
         sch_sd_dates
         sch_eff_start
         sch_eff_end
      go-on(F5 CTRL-D) with frame sched_data.

      if lastkey = keycode("F5")
      or lastkey = keycode("CTRL-D")
      then do:
         /* WARN THE USER WHEN A CONTAINER/SHIPPER IS FOUND FOR THE
          * SALES ORDER. */
         find scx_ref where
              scx_type  = 1        and
              scx_order = sch_nbr  and
              scx_line  = sch_line
         no-lock.

         find first abs_mstr where
                    abs_shipfrom = scx_shipfrom     and
                    abs_dataset  = "sod_det"        and
                    abs_order    = sch_nbr          and
                    abs_line     = string(sch_line)
         no-lock no-error.
         if available abs_mstr then do:
            /* SHIPPER OR CONTAINER EXISTS FOR SCHEDULE LINE */
            {pxmsg.i &MSGNUM=8304 &ERRORLEVEL=2}
         end.

         del-yn = yes.
         {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=del-yn}
         if del-yn = no
            then undo, retry.

         if sod_curr_rlse_id[schtype] = sch_rlse_id then
            sod_curr_rlse_id[schtype] = "".

         {gprun.i ""rcschdel.p"" "(input recid(sch_mstr), input no)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         /* Return to prompt is schedule was not found */
         if available sch_mstr
         then do:
            hide frame sched_data no-pause.
            next.
         end.

         /* Update Remote Database */
         {gprun.i ""rcrsdup.p"" "(input recid(sod_det))"}
/*GUI*/ if global-beam-me-up then undo, leave.


         clear frame sched_data.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame sched_data = F-sched_data-title.
         clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
         next.

      end.

      /* VALIDATE SHIP/DELIVERY PATTERN CODE */
      if not ({gpcode.v sch_sd_pat}) then do:
         /* Value must exist in Generalized Codes */
         {pxmsg.i &MSGNUM=716 &ERRORLEVEL=3}
         next-prompt sch_sd_pat with frame sched_data.
         undo , retry.
      end.

      if not ({gpcode.v sch_prp_int }) then do:
         /* Value must exist in Generalized Codes */
         {pxmsg.i &MSGNUM=716 &ERRORLEVEL=3}
         next-prompt sch_prp_int with frame sched_data.
         undo , retry.
      end.

      if not ({gpcode.v sch_prp_ext}) then do:
         /* Value must exist in Generalized Codes */
         {pxmsg.i &MSGNUM=716 &ERRORLEVEL=3}
         next-prompt sch_prp_ext with frame sched_data.
         undo , retry.
      end.

      if sch_pcs_date = ?
         and so_cum_acct
      then do:
         /* Invalid Prior Cum Start Date */
         {pxmsg.i &MSGNUM=8240 &ERRORLEVEL=3}
         next-prompt sch_pcs_date with frame sched_data.
         undo , retry.
      end.

      if sch_cumulative then do:
         find first schd_det
              where schd_type = sch_type
                and schd_nbr = sch_nbr
                and schd_line = sch_line
                and schd_rlse_id = sch_rlse_id
                and schd_cum_qty < sch_pcr_qty
         no-lock no-error.
         if available schd_det then do:
            {pxmsg.i &MSGNUM=6021 &ERRORLEVEL=3}
            undo , retry.
         end.
      end.

      if new sch_mstr and sch_eff_start < today then do:
         /* Invalid Date */
         {pxmsg.i &MSGNUM=27 &ERRORLEVEL=3}
         next-prompt sch_eff_start with frame sched_data.
         undo , retry.
      end.

      if sch_eff_end < sch_eff_start then do:
         /* Start Date must be prior to End Date */
         {pxmsg.i &MSGNUM=4 &ERRORLEVEL=3}
         next-prompt sch_eff_start with frame sched_data.
         undo, retry.
      end.

   end.
/*GUI*/ if global-beam-me-up then undo, leave.


   if cmmts then do:
      cmtindx = sch_cmtindx.
      global_ref = scx_shipto.

      {gprun.i ""gpcmmt01.p"" "(input ""cs"")"}
/*GUI*/ if global-beam-me-up then undo, leave.

      sch_cmtindx = cmtindx.

      view frame a.
   end.

   /* CUSTOMER RECEIPTS UPDATE */
   {gprun.i ""rcpsmtc.p"" "(input recid(sch_mstr), input no)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   view frame a.

   /* DO DETAIL MAINTENANCE */
   {gprun.i ""rcscmtb.p"" "(input recid(sch_mstr))"}
/*GUI*/ if global-beam-me-up then undo, leave.


   /* AUTHORIZATIONS */
   FORM /*GUI*/ 
      
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
sch_fab_qty       colon 11
      sch_fab_strt      colon 39
      sch_fab_end       colon 60
      sch_raw_qty       colon 11
      sch_raw_strt      colon 39
      sch_raw_end       colon 60
    SKIP(.4)  /*GUI*/
with frame res_auth_data width 80
   
   attr-space side-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-res_auth_data-title AS CHARACTER.
 F-res_auth_data-title = (getFrameTitle("RESOURCE_AUTHORIZATION_DATA",38)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame res_auth_data = F-res_auth_data-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame res_auth_data =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame res_auth_data + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame res_auth_data =
  FRAME res_auth_data:HEIGHT-PIXELS - RECT-FRAME:Y in frame res_auth_data - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME res_auth_data = FRAME res_auth_data:WIDTH-CHARS - .5. /*GUI*/


   /* SET EXTERNAL LABELS */
   setFrameLabels(frame res_auth_data:handle).

   if new sch_mstr then do:
      {gprun.i ""rcpsmta.p"" "(input recid(sch_mstr), input recid(sod_det))"}
/*GUI*/ if global-beam-me-up then undo, leave.

   end.

   ststatus = stline[3].
   status input ststatus.

   do on endkey undo , leave:
      update
         sch_fab_qty
         sch_fab_strt
         sch_fab_end
         sch_raw_qty
         sch_raw_strt
         sch_raw_end
      with frame res_auth_data.
   end.

   hide frame res_auth_data.

   yn = no.
   if sch_rlse_id <> sod_curr_rlse_id[schtype] then do:

      /* Make this schedule Active ? */
      {pxmsg.i &MSGNUM=6001 &ERRORLEVEL=1 &CONFIRM=yn}

      if yn then do:
         assign
            this_eff_start = sch_eff_start
            sch_recid = recid(sch_mstr).

         find sch_mstr where sch_type = schtype
                         and sch_nbr = sod_nbr
                         and sch_line = sod_line
                         and sch_rlse_id = sod_curr_rlse_id[schtype]
         exclusive-lock no-error.

         if available sch_mstr then
            assign
               sch_eff_end = this_eff_start.

         find sch_mstr where recid(sch_mstr) = sch_recid
         exclusive-lock.

         assign
            sch_eff_end = ?
            sod_curr_rlse_id[schtype] = sch_rlse_id.
      end.

   end.

   sod_sched_chgd = yes.

   /* UPDATE REMOTE DATABASE SCHEDULE IF THERE IS ONE*/
   {gprun.i ""rcrshup.p"" "(input recid(sch_mstr))"}
/*GUI*/ if global-beam-me-up then undo, leave.


   /* UPDATE REMOTE DATABASE SO DETAIL IF THERE IS ONE*/
   {gprun.i ""rcrsdup.p"" "(input recid(sod_det))"}
/*GUI*/ if global-beam-me-up then undo, leave.


   release sod_det.

end.
/*GUI*/ if global-beam-me-up then undo, leave.

